<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: YKMZ
  Date: 2022/9/19
  Time: 17:04
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>pageContext作用域</title>
</head>
<body>
    <%
        //1. 定义图书列表
        List<String> books = new ArrayList<String>();
        books.add("《三国演义》");
        books.add("《水浒传》");
        books.add("《西游记》");
        books.add("《红楼梦》");

        //2. 将数据放到pageContext作用域
        pageContext.setAttribute("books",books);
        //3. 再从当前页面取出数据
        List<String> books1 = (List<String>) pageContext.getAttribute("books");
        //4. 打印图书
        out.println("[PageContext作用域]图书列表如下：<br>");
        for (String book : books1) {
            out.println(book + "<br>");
        }
    %>
</body>
</html>
